package com.sanploy.manage.controller;

import com.sanploy.common.domain.dto.AdminDto;
import com.sanploy.common.domain.dto.Pages;
import com.sanploy.common.vo.BaseException;
import com.sanploy.manage.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by zhu yingzhi on 2017/10/16.
 * @author yingzhi zhu
 * 管理员 接口路由
 */
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * 添加管理员
     * @param admin 详见 AdminDto类
     * @return
     */
    @PostMapping("")
    public Object addAdmin(AdminDto admin) throws BaseException {
        return adminService.addAdmin(admin);
    }

    /**
     * 根据Id 查找管理员
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Object findAdminById(@PathVariable Long id) throws BaseException {
           return adminService.findAdminById(id);
    }

    /**
     * 分页查找管理员
     * @param pages 详见
     * @return
     */
    @GetMapping("")
    public Object findAdmin(Pages pages) throws BaseException {
        return adminService.findAdmin(pages);
    }

    /**
     * 修改管理员信息
     * @param adminDto
     * @return
     */
    @PostMapping("{id}")
    public Object editAdmin(AdminDto adminDto) throws BaseException {
        return adminService.editAdmin(adminDto);
    }

    /**
     * 删除管理员
     * @param  id
     * @return
     */
    @GetMapping("/delete/{id}")
    public Object deleteAdmin(@PathVariable Long id) throws BaseException {
        return adminService.deleteAdmin(id);
    }





}
